#include "HttpServer.hpp"
#include "Util.hpp"
#include "Protocol.hpp"
#include <iostream>
#include <string>
#include <memory>

using namespace std;

const static string defaultPath = "./webRoot/index.html";

string HttpHandler(const string &url)
{
    // 解析请求
    Request req;
    req.Deserialization(url);

    // 构建响应
    Response res;
    res.LoadInfo(req);

    // 响应
    string ret;
    res.Serialization(&ret);
    return ret;
}

int main()
{
    unique_ptr<HttpServer::Server> psvr(new HttpServer::Server(HttpHandler));

    psvr->Init();
    psvr->Start();

    return 0;
}
